<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include_once 'MySqlDataAccessHelper.php';

/**
 * Description of Word
 *
 * @author Phuong Vu
 */
class Listen {
    public $ID;
    public $IDLesson;
    public $Video;
    public $Script;
    public $isDone;

    function loadListenByLesson($idLesson) {
        try {
            $connection = new MySqlDataAccessHelper();
            $connection->open();

            $sql = "select* from Listen where IDLesson =" . $idLesson;
            $result = $connection->executeQuery($sql);
            $listListen = array();
            while ($row = mysql_fetch_object($result)) {
                $temp = new Listen();
                $temp = $row;

                $listListen[] = $temp;
            }

            $connection->close();

            return $listListen;
        } catch (Exception $e) {
            $connection->close();
            return false;
        }
    }
    
    function getListenByID($idListen) {
        try {
            $connection = new MySqlDataAccessHelper();
            $connection->open();
            $listen = new Listen();
            $sql = "select* from Listen where ID =" . $idListen;
            $result = $connection->executeQuery($sql);
            
            while ($row = mysql_fetch_object($result)) {
                $listen =$row;
              
            }
            
            $connection->close();
            return $listen;
            
        } catch (Exception $e) {
            $connection->close();
            return false;
        }
    }

}